package com.itheima04;

import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeMap;

public class HomeWork03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String s1 = sc.nextLine();

        TreeMap<Character, Integer> tm = new TreeMap<>(new Comparator<Character>() {
            @Override
            public int compare(Character o1, Character o2) {
                int i = o1.compareTo(o2);
                return i;
            }
        });


        for (int i = 0; i < s1.length(); i++) {
            char c = s1.charAt(i);
            if (tm.containsKey(c)) {
                Integer integer = tm.get(c);
                integer++;
                tm.put(c, integer);
            } else {
                tm.put(c, 1);
            }
        }
        tm.forEach((key, value) -> System.out.println(key + "----" + value));
    }
}
